<?php
require_once '../include/common.inc.php';
//require_once '../login/login_check.php';
$query;
$type;
if($actiontype == "0"){//修改
	if ($tablename == "userinfo")
	{
		$type = 0;
		$query = "update $tablename SET 
				name = '$username',
				type = '$type',
				tel = '$tel',
				email = '$email'";
	}
	else if ($tablename == "softinfo")
	{
		$type = 1;
		$query = "update $tablename SET 
				name = '$softname',
				code = '$code',
				type = '$softtype',
				softver = '$softver',
				filever = '$filever',
				updatetype = '$updatetype',
				softdownloadurl = '$softurl',
				filedownloadurl = '$fileurl',
				memo = '$memo'";
	}
	else if ($tablename == "package")
	{
		$type = 2;
		$query = "update $tablename SET 
				name = '$packagename',
				money = '$money',
				service = '$service',
				memo = '$memo'";
	}
	$query .= " where id='$id'";
	$db->query($query);
	echo"<script>alert('成功修改记录');</script>";
}
else
{
	if ($tablename == "userinfo")
	{
		$type = 0;
		$query = "INSERT INTO $tablename SET 
				name = '$username',
				type = '$type',
				tel = '$tel',
				email = '$email'";
	}
	else if ($tablename == "softinfo")
	{
		$type = 1;
		$query = "INSERT INTO $tablename SET 
				name = '$softname',
				type = '$softtype',
				softver = '$softver',
				filever = '$filever',
				updatetype = '$updatetype',
				softdownloadurl = '$softurl',
				filedownloadurl = '$fileurl',
				memo = '$memo'";
	}
	else if ($tablename == "package")
	{
		$type = 2;
		$query = "INSERT INTO $tablename SET 
				name = '$packagename',
				money = '$money',
				service = '$service',
				memo = '$memo'";
	}
	$db->query($query);
	echo"<script>alert('成功添加记录');</script>";
}
//echo $query;
header("location:list.php?type=".$type);
?>